<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-09-30 15:27:29
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Models;

use App\Traits\MaterialTrait;
use App\Traits\SoftDeletesTrait;
use App\Traits\AttachmentTrait;
use App\Traits\AutoCodeTrait;

class MarketOffer extends BaseModel
    {
    use SoftDeletesTrait;
    use AutoCodeTrait;
    use MaterialTrait;
    public $timestamps = true;
    public $table = "basedata_market_offer";
    protected $guarded = [];

    protected $casts = [];

    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'MARKET_OFFER';
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'OrderStatus');
            });
        }
    /**
     * 优惠报价单
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     * @author sunkaiyuan
     */
    public function promotions()
        {
        return $this->hasMany(MarketOfferPromotions::class, "offer_id");
        }

    /**
     * 区域
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author sunkaiyuan
     */
    public function department()
        {
        return $this->belongsTo(Department::class);
        }
    }
